<template>
	<view class="card_all" :style="{'background-color':bgcolor}">
		<view class="card" :style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/bg.png'+')'}">
			<!-- 头部区域 -->
			<view class="card_head flex-column-between font11 font-ffffff">
				<view class="flex-row-between">
					<view @click="Onopen('popup1')" class="card_button card_but_a flex-row-center"
						:style="{'background-color':color1}">赠送记录
					</view>
					<view class="cardH_people flex-row-center font-646464">
						<text>已有</text>
						<view :style="{'color': color1}">{{otherObj.number}}</view>
						<text>人集齐纽卡赢得大礼</text>
					</view>
					<view @click="Onopen('popup2')" class="card_button card_but_a flex-row-center"
						:style="{'background-color':color1}">活动规则
					</view>
				</view>
				<view class="flex-row-between">
					<view v-if="datainfo.is_recharge==0"></view>
					<view v-else @click="Onopen('popup3')" class="card_button card_but_a flex-row-center"
						:style="{'background-color':color1}">充值记录
					</view>
					<view @click="goNext('/pages/activity/common/prizeList')"
						class="card_button card_but_a flex-row-center" :style="{'background-color':color1}">我的奖品
					</view>
					<!-- <view class="card_button card_but_b flex-row-center" :style="{'background-color':color1}">分享
					</view> -->
				</view>
			</view>
			<!-- 我的奖品 -->
			<view class="card_prize flex-row-center font11 font-ffffff" :style="{'background-color':color1}"></view>
			<!-- 抽卡赢好礼 -->
			<view class="card_win bg-cover font15 font-ffffff" @click="Ondraw"
				:style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/b1.png'+')'}">抽卡赢好礼 X
				{{othermember.number}}
			</view>
			<!-- 卡片 -->
			<view class="card_bos flex-row-between">
				<!--  #ifdef  MP-WEIXIN -->
				<view v-for="(item,index) in cardList" :key="index" class="card_list"
					:style="{'width':card.Boxwidth,'height':card.Boxheight}" @click="Onopen('popup6',item)">
				<!--  #endif -->
				<!--  #ifdef  H5 -->
				<view v-for="(item,index) in cardList" :key="index" class="card_list"
					:style="{'width':card.Boxwidth,'height':card.Boxheight}"  @click="Onopen('popup5',{give:true})">
				<!--  #endif -->
					<!-- 卡片 -->
					<view class="card_box bg-cover font-ffffff flex-row-center"
						:class="cardList.length==6?'font25':'font30'"
						:style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/'+(item.count>0?'card_a':'card_b')+'.png'+')','width':card.width,'height':card.height}">
						{{item.count>0?item.name:''}}
					</view>
					<block v-if="item.count>0">
						<view class="card_num font12 font-ffffff flex-row-center" :style="{'background-color':color2}">
							{{item.count}}
						</view>
						<!-- <view class="card_name font-ffffff">{{item.name}}</view> -->
						<view class="card_give flex-row-center font-ffffff font11"
							:style="{'background-color':color2,'left':card.giveLeft}">可转赠</view>
					</block>
				</view>
			</view>
			<!-- 助力 -->
			<view class="card_help" v-if="helpList.length>0">
				<swiper class="card_swiper" :autoplay="true" :interval="3000" :vertical="true" :disable-touch="true"
					:circular="true">
					<swiper-item v-for="(item, index) in helpList" :key="index"
						@click="goNext('/pages/activity/common/help?data=mode.self,id.' + id)">
						<view class="cardH_bos flex-row-center font12">
							<text :style="{'color': color1}">{{item.user_info.name}}</text>
							<view class="font-646464">帮你助力一次</view>
							<image src="https://static.newbeaconhotels.com/app/hotel/activity/more.png" mode=""></image>
						</view>
					</swiper-item>
				</swiper>
			</view>
			<!-- 抽卡 -->
			<view class="card_draw flex-row-between font-ffffff font15">
				<view @click="Onprize" class="cardD_box bg-cover"
					:style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/b2.png'+')'}">兑换礼包
				</view>
				<!--  #ifdef  MP-WEIXIN -->
				<button class="cardD_box bg-cover font-ffffff font15" open-type="share" data-button="help"
					:style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/b3.png'+')'}">求助好友</button>
				<!--  #endif -->
				<!--  #ifdef  H5 -->
				<view class="cardD_box bg-cover" @click="Onopen('popup5',{help:true})"
					:style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/b3.png'+')'}">求助好友
				</view>
				<!--  #endif -->
			</view>
			<!-- 活动规则 -->
			<view class="card_rule font-323232 font13 tc">
				<view class="font-323232 font15 font-b">活动规则</view>
				<rich-text :nodes="datainfo.rule"></rich-text>
			</view>
			<!-- 奖品 -->
			<view class="box">
				<view class="title">奖品内容</view>
				<view class="content prize">
					<view class="prize-item flex-row-between" v-for="(item, index) in datainfo.prize" :key="index">
						<view class="circle"></view>
						<view class="con">
							<view class="inner">
								<text>{{item.tip}}：</text>
								<text class="font-646464">{{item.name}}</text>
							</view>
						</view>
						<view class="number">{{item.number ? item.number : 0}}份</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 赠送记录 -->
		<uni-popup ref="popup1" type="center" :mask-click="false">
			<view class="popup_bos popup1_bos flex-column-center" v-if="LoadIf1">
				<view class="popup_title font15 font-1e1e1e tc font-b">赠送记录</view>
				<view class="popup1_head font14 flex-row-around">
					<view @click="Onpop1head('del')" :style="{'color':popup1index=='del'?color1:'#646464'}">送出记录</view>
					<view @click="Onpop1head('add')" :style="{'color':popup1index=='add'?color1:'#646464'}">收到记录</view>
				</view>
				<view class="popup_border"></view>
				<LoadMore ref="LoadMore1" :token="true" :diffHeight="0" :boxHeight="490" :initData="initData1"
					@dataRefresh='dataRefresh1'>
					<view class="popup1_box">
						<view class="popup1_list" v-for="(item,index) in GiveList" :key="index">
							<view class="popup1_data flex-row-start">
								<view class="popup1_image bg-cover flex-row-center font-ffffff font14"
									:style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/card_a.png'+')'}">
									{{item.name}}
								</view>
								<view class="popup1_all">
									<view class="font-1e1e1e font12 ellipsis" v-if="popup1index=='del'">
										<text>赠送一张“{{item.name}}”卡给好友</text>
										<text class="marginL-10"
											:style="{'color':color1}">{{item.flag==1?'***待领取':item.username}}</text>
									</view>
									<view class="font-1e1e1e font12 ellipsis" v-if="popup1index=='add'">
										<text>您的好友</text>
										<text class="marginLR-5" :style="{'color':color1}">{{item.username}}</text>
										<text>赠送一张“{{item.name}}”卡给您</text>
									</view>
									<view class="popup1_time font-646464 font11 flex-row-between">
										<text>{{item.sendtime}}</text>
										<view @click="OngetBack(item)" v-if="popup1index=='del'&&item.flag==1"
											class="flex-row-center" :style="{'border-color':color2,'color':color2}">索回
										</view>
									</view>
								</view>
							</view>
							<view class="popup_border"></view>
						</view>
					</view>
				</LoadMore>
			</view>
			<view class="popup_close" @click="Onclose('popup1')">
				<image src="https://static.newbeaconhotels.com/app/hotel/close-line.png" mode=""></image>
			</view>
		</uni-popup>
		<!-- 活动规则 -->
		<uni-popup ref="popup2" type="center" :mask-click="false">
			<view class="popup_bos popup2_bos flex-column-center">
				<view class="popup_title font15 font-1e1e1e tc font-b">活动规则</view>
				<scroll-view :scroll-top="scrollTop" scroll-y="true" class="popup2_rule">
					<rich-text class="font13 font-323232" :nodes="datainfo.rule"></rich-text>
				</scroll-view>
				<view @click="Onclose('popup2')" class="popup_button font15 font-ffffff flex-row-center">我知道了</view>
			</view>
		</uni-popup>
		<!-- 充值抽卡记录 -->
		<uni-popup ref="popup3" type="center" :mask-click="false">
			<view class="popup_bos popup3_bos flex-column-center" v-if="LoadIf2">
				<view class="popup_title font15 font-1e1e1e tc font-b">充值抽卡记录</view>
				<view class="popup3_box">
					<view class="popup_border"></view>
					<LoadMore ref="LoadMore2" :token="true" :diffHeight="0" :boxHeight="470" :initData="initData2"
						@dataRefresh='dataRefresh2'>
						<view class="popup3_all">
							<view class="popup3_list" v-for="(item,index) in BuyList" :key="index">
								<view class="font-1e1e1e font12 ellipsis">
									<text>消耗</text>
									<text class="marginLR-5"
										:style="{'color':color1}">{{item.money}}{{item.type}}</text>
									<text>获得{{item.number}}次抽卡机会</text>
								</view>
								<view class="popup3_time font-646464 font11">{{item.createtime}}</view>
							</view>
							<view class="popup_border"></view>
						</view>
					</LoadMore>
				</view>
				<view @click="goNext('/pages/activity/common/recharge?id=' + id,'popup3')"
					class="popup_button font15 font-ffffff flex-row-center">去充值</view>
			</view>
			<view class="popup_close" @click="Onclose('popup3')">
				<image src="https://static.newbeaconhotels.com/app/hotel/close-line.png" mode=""></image>
			</view>
		</uni-popup>
		<!-- 抽卡弹窗 -->
		<uni-popup ref="popup4" type="center" :mask-click="false">
			<view class="popup4_bos">
				<view class="popup4_card" :class="flip?'flipclass':''">
					<view class="pop4C_bos">
						<!-- 正面 -->
						<view class="pop4C_all cardjust flex-column-between flex-center">
							<view class="popup4_title"></view>
							<view class="pop4C_box bg-cover"
								:style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/card_b.png'+')'}">
							</view>
							<view class="popup4_button_is"></view>
						</view>
						<!-- 反面 -->
						<view class="pop4C_all cardback flex-column-between flex-center">
							<view class="popup4_title font20 font-ffffff">恭喜您获得此卡</view>
							<view class="pop4C_box bg-cover flex-row-center"
								:style="{'background-image':'url('+imgFullUrl+'/app/game_hotel/'+bgID+'/card_a.png'+')'}">
								{{lucktext}}
							</view>
							<view @click="Onclose('popup4')" class="popup4_button font-ffffff font17 flex-row-center">
								继续抽卡</view>
							<image class="popup4_light" src="https://static.newbeaconhotels.com/app/hotel/activity/light.png"
								mode=""></image>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 错误弹窗提示 -->
		<uni-popup ref="popup5" type="center" :mask-click="false">
			<view class="popup_bos popup5_bos flex-column-center">
				<image class="popup5_image" src="https://static.newbeaconhotels.com/app/hotel/activity/pop.png" mode=""></image>
				<view class="popup5_title font-1e1e1e font16 font-b">{{popup5.title}}</view>
				<view class="popup5_info font-1e1e1e font13">{{popup5.info}}</view>
				<view class="popup5_button font-ffffff font15 flex-row-start">
					<!-- 左边按钮 -->
					<view v-if="popup5.button1_is!='help'" class="popup5_button1 flex-row-center"
						:class="popup5.button2==''?'popup5_button1_100':'popup5_button1_50'"
						@click="Onpop5(popup5.button1_is)">{{popup5.button1}}
					</view>
					<!--  #ifdef  MP-WEIXIN -->
					<button v-if="popup5.button1_is=='help'" class="popup5_button1 flex-row-center font-ffffff font15"
						:class="popup5.button2==''?'popup5_button1_100':'popup5_button1_50'" open-type="share"
						data-button="help">求助好友</button>
					<!--  #endif -->
					<!--  #ifdef  H5 -->
					<view v-if="popup5.button1_is=='help'" class="popup5_button1 flex-row-center font-ffffff font15"
						:class="popup5.button2==''?'popup5_button1_100':'popup5_button1_50'"
						@click="Onpop5(popup5.button1_is)" data-button="help">求助好友</view>
					<!--  #endif -->
					<!-- 右边边按钮 -->
					<view v-if="popup5.button2!=''" class="popup5_button2 flex-row-center"
						@click="Onpop5(popup5.button2_is)">{{popup5.button2}}</view>
				</view>

			</view>
			<view class="popup_close" @click="Onclose('popup5')">
				<image src="https://static.newbeaconhotels.com/app/hotel/close-line.png" mode=""></image>
			</view>
		</uni-popup>
		<!-- 操作文案提示 -->
		<uni-popup ref="popup6" type="center" :mask-click="false">
			<view class="popup_bos popup6_bos flex-column-center">
				<view class="popup_title font15 font-1e1e1e tc font-b">提示</view>
				<view class="popup6_box">
					<view class="font-323232 font14 font-b">{{popup6.title}}</view>
					<view class="font-505050 font13 popup6_margin" v-if="popup6.type!='give'">说明</view>
					<view class="font-505050 font13">{{popup6.info}}</view>
				</view>
				<view class="flex-row-start popup6_button font-ffffff font15">
					<view class="popup6_button1 flex-row-center" @click="Onclose('popup6')">取消</view>
					<view v-if="popup6.type!='give'" class="popup6_button2 flex-row-center" @click="Onpop6">
						{{popup6.button}}
					</view>
					<!--  #ifdef  MP-WEIXIN -->
					<button v-else class="popup6_button2 flex-row-center font-ffffff font15" open-type="share"
						data-button="give">{{popup6.button}}</button>
					<!--  #endif -->
				</view>
			</view>
		</uni-popup>
		<!-- 中奖弹窗 -->
		<uni-popup ref="popup7" type="center" :mask-click="false">
			<view class="popup_bos popup7_bos flex-column-center">
				<view class="popup_title font15 font-1e1e1e tc font-b">恭喜您获得</view>
				<view class="popup7_info font14 font-1e1e1e">{{luckObj.name}}</view>
				<image class="popup7_image" mode="widthFix" :src="luckObj.image"></image>
				<view class="flex-row-start popup7_button font-ffffff font15">
					<view class="popup7_button1 flex-row-center" @click="Onclose('popup7')">继续抽奖</view>
					<view class="popup7_button2 flex-row-center"
						@click="goNext('/pages/activity/common/prizeList','popup7')">去领取</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import LoadMore from "@/components/j-loadMore/index.vue";
	export default {
		components: {
			LoadMore
		},
		data() {
			return {
				type: 'normal', //类型
				Gid: null, //领取卡片ID
				datainfo: {}, //数据
				otherObj: {}, //其他数据
				othermember: {}, //其他数据
				imgFullUrl: this.$Config.http_static, //图片地址
				//卡片的高宽
				card: {
					width: '',
					Boxwidth: '',
					height: '',
					Boxheight: '',
					giveLeft: ''
				},
				cardList: [], //卡片
				id: null, //活动ID
				bgID: 4, //背景图ID
				bgcolor: '', //背景颜色
				color1: '', //颜色(轮播+按钮)
				color2: '', //颜色(卡)
				scrollTop: 0, // 滚动条位置
				helpList: [], //助力
				popup1data: [], //赠送记录数据
				drawif: true, //防止多次抽卡
				flip: false, //旋转样式
				lucktext: '', //抽中的卡片
				//错误文字5
				popup5: {
					title: '',
					info: '',
					button1: '',
					button1_is: '',
					button2: '',
					button2_is: ''
				},
				//错误文字6
				popup6: {
					title: '',
					info: '',
					type: '',
					button: '',
				},
				idInfo: {}, //分享
				userInfo: {}, //个人信息
				luckObj: {}, //奖品
				giveObj: {}, //送出的卡片
				popup1index: 'del', //赠送记录下标
				// 传参数据
				initData1: {
					url: 'cardgive',
					param: {
						type: 'del',
						activity_id: null,
					}
				},
				LoadIf1: false, //加载显示
				GiveList: [], //收到数据
				// 传参数据
				initData2: {
					url: 'getBuyList',
					param: {
						activity_id: null,
					}
				},
				LoadIf2: false, //加载显示
				BuyList: [], //收到数据
				wxSdk: false, //H5api
			}
		},
		onLoad: function(options) {
			let params = {}
			let that = this
			if (this.$Route.query.data) {
				params = this.$base.OnWxoptions(this.$Route.query.data)
			}else if (this.$Route.query.scene) {
				params = this.$base.OnWxoptions(this.$Route.query.scene)
			}else{
				params = options
			}
			this.type = params.type
			this.id = params.id
			this.bgID = params.id
			this.initData1.param.activity_id = params.id
			this.initData2.param.activity_id = params.id
			//领取卡牌
			if (this.type == 'give') {
				this.Gid = params.Gid
				this.popup5 = {
					title: '领取提示',
					info: '您有一张纽卡待领取~',
					button1: '立即领取',
					button1_is: 'give',
					button2: '',
					button2_is: ''
				}
				this.$refs.popup5.open()
			}
			this.prohibit = false
			this.idInfo = uni.getStorageSync("idInfo");
			uni.getStorage({
				key: 'userInfo',
				success: function(res) {
					that.userInfo = res.data
					//我的助力榜
					that.Onhelp()
					// #ifdef H5
					that.$wxapi.OnwxSdk().then(res => {
						that.wxSdk = res.code == 1 ? true : false
					})
					// #endif
				}
			});
			//活动详情
			this.Oninfo()
			//获取卡片
			this.OnMyPlay()
			//获取抽奖信息
			this.OngetMessage()
		},
		methods: {
			//活动详情
			Oninfo() {
				this.$Http({
					url: 'getActivity',
					data: {
						activity_id: this.id
					},
				}).then(res => {
					if (res.code == 1) {
						res.data.rule = res.data.rule ? res.data.rule.replace(/\<img/g,
							'<img style="display: block;max-width: 100%;height: auto"') : ''
						this.bgcolor = res.data.bjs
						this.color1 = res.data.zsd
						this.color2 = res.data.fsd
						this.datainfo = res.data
						// #ifdef H5
						if (this.wxSdk) {
							let name = this.userInfo.user ? this.userInfo.user.name : '有人'
							let paramStr = 'Pid.' + this.idInfo.Pid + ',Fid.' + this.idInfo.Fid + ',id.' + this
								.id + ',type.normal'
							if (this.idInfo.Cid) {
								paramStr = paramStr + ',Cid.' + this.idInfo.Cid
							}
							this.share.type = true
							this.share.title = res.data.help.title
							this.share.desc = res.data.help.describe
							this.share.imageUrl = this.imgFullUrl + res.data.help.image
							this.share.path = '/pages/activity/card/index?scene=' + paramStr
							console.log(this.share,'查看')
							this.Onshare()
						}
						// #endif
					}
				});
			},
			//获取卡片
			OnMyPlay(type, resolved) {
				this.$Http({
					url: 'getMyPlay',
					data: {
						activity_id: this.id
					},
					token: true,
				}).then(res => {
					if (res.code == 1) {
						this.cardList = []
						res.data.forEach((item, index) => {
							if (index < 6) {
								this.cardList.push(item)
							}
						})
						if (this.cardList.length == 6) {
							this.card.width = '100rpx'
							this.card.Boxwidth = '114rpx'
							this.card.height = '122rpx'
							this.card.Boxheight = '154rpx'
							this.card.giveLeft = '0rpx'
						}
						if (this.cardList.length == 5) {
							this.card.width = '118rpx'
							this.card.Boxwidth = '132rpx'
							this.card.height = '144rpx'
							this.card.Boxheight = '176rpx'
							this.card.giveLeft = '9rpx'
						}
						if (this.cardList.length == 4) {
							this.card.width = '136rpx'
							this.card.Boxwidth = '150rpx'
							this.card.height = '166rpx'
							this.card.Boxheight = '198rpx'
							this.card.giveLeft = '18rpx'
						}
						// this.cardList = res.data
					}
					if (type) {
						resolved(true)
					}
				});
			},
			//获取抽奖信息
			OngetMessage(type, resolved) {
				this.$Http({
					url: 'getMessage',
					data: {
						activity_id: this.id
					},
					token: true
				}).then(res => {
					if (res.code == 1) {
						this.otherObj = res.data
						this.othermember = res.data.member
					}
					if (type) {
						resolved(true)
					}
				});
			},
			//我的助力榜
			Onhelp(type, resolved) {
				this.$Http({
					url: 'help',
					token: true,
					data: {
						activity_id: this.id,
						user_id: this.userInfo.user.user_id,
						page: 1,
						limit: 100,
					},
					token: true
				}).then(res => {
					if (res.code == 1) {
						this.helpList = res.data.data
					}
					if (type) {
						resolved(true)
					}
				});
			},
			//抽卡
			Ondraw() {
				//防止2次请求
				if (!this.drawif) {
					return
				}
				this.drawif = false
				this.$Http({
					url: 'luckDraw',
					data: {
						activity_id: this.id
					},
					token: true
				}).then(res => {
					let that = this
					this.OnMyPlay()
					this.OngetMessage()
					//抽中
					if (res.code == 1) {
						this.lucktext = res.msg
						this.$refs.popup4.open()
						setTimeout(function() {
							that.flip = true
							that.drawif = true
						}, 500);
					} else if (res.code == 0) {
						this.lucktext = ''
						this.flip = false
						this.drawif = true
						if (res.data == 1) {
							this.popup5 = {
								title: '活动提示',
								info: '本轮抽卡已结束',
								button1: '首页',
								button1_is: 'home',
								button2: '',
								button2_is: ''
							}
							this.$refs.popup5.open()
						} else if (res.data == 2) {
							this.popup5 = {
								title: '您的抽卡次数已用完',
								info: '邀请好友助力获得更多抽卡次数或充值抽卡次数',
								button1: '求助好友',
								button1_is: 'help',
								button2: this.datainfo.is_recharge == 0 ? '' : '去充值',
								button2_is: this.datainfo.is_recharge == 0 ? '' : 'recharge'
							}
							this.$refs.popup5.open()
						} else if (res.data == 3) {
							this.popup5 = {
								title: '抽卡提示',
								info: '感谢参与，今日卡已抽完，请明天继续',
								button1: '关闭',
								button1_is: 'close',
								button2: '',
								button2_is: ''
							}
							this.$refs.popup5.open()
						} else if (res.data == 4) {
							this.popup5 = {
								title: '抽卡提示',
								info: '很遗憾 未抽中~',
								button1: '继续抽卡',
								button1_is: 'close',
								button2: '',
								button2_is: ''
							}
							this.$refs.popup5.open()
						} else if (res.data == 4) {
							this.popup5 = {
								title: '抽卡提示',
								info: '非常抱歉,卡片库存不足,请稍后在试试~',
								button1: '我知道了',
								button1_is: 'close',
								button2: '',
								button2_is: ''
							}
							this.$refs.popup5.open()
						} else {
							uni.showToast({
								icon: 'none',
								duration: 3000,
								title: res.msg
							});
						}
					}
				});
			},
			//抽奖
			Onprize() {
				let type = true
				this.cardList.forEach(item => {
					if (item.count <= 0) {
						type = false
					}
				})
				if (type) {
					this.popup6 = {
						title: '您确定兑换礼品吗?',
						info: '礼品兑换成功后，系统自动发放到您奖品列表中，请您到奖品列表中手动领取对应奖品。',
						type: 'prize',
						button: '立即兑换'
					}
					this.$refs.popup6.open()
				} else {
					this.popup5 = {
						title: '兑换提示',
						info: '很遗憾 您并未集齐所有纽卡~',
						button1: '我要抽卡',
						button1_is: 'close',
						button2: '',
						button2_is: ''
					}
					this.$refs.popup5.open()
				}
			},
			//弹窗事件
			Onpop5(e) {
				let that = this
				// #ifdef H5
				//求助好友
				if (e == 'help') {
					uni.showModal({
						title: '求助提示',
						confirmText: '确认',
						confirmColor: that.color1,
						showCancel: false,
						content: '浏览器暂不支持求助好友,请切换到微信小程序',
						success: function(res) {
							if (res.confirm) {
								that.$refs.popup5.close()
							}
						}
					});
				}
				// #endif
				if (e == 'home') {
					this.$Router.replaceAll('/pages/home/index')
				}
				if (e == 'recharge') {
					if (this.datainfo.is_recharge == 0) {
						uni.showToast({
							icon: 'none',
							duration: 3000,
							title: '此活动不参与充值'
						});
						return
					}
					this.$Router.push('/pages/activity/common/recharge?id=' + this.id)
					this.$refs.popup5.close()
				}
				if (e == 'close') {
					this.lucktext = ''
					this.flip = false
					this.$refs.popup5.close()
				}
				if (e == 'give') {
					this.$Http({
						url: 'getGive',
						token: true,
						data: {
							id: this.Gid,
							activity_id: this.id
						},
					}).then(res => {
						if (res.code == 1) {
							this.OnMyPlay()
							this.$refs.popup5.close()
						} else {
							this.popup5 = {
								title: '领卡提示',
								info: res.msg,
								button1: '我知道了',
								button1_is: 'close',
								button2: '',
								button2_is: ''
							}
						}
					});
				}
			},
			//弹窗事件6
			Onpop6() {
				//兑奖
				if (this.popup6.type == 'prize') {
					this.$refs.popup6.close()
					//合成卡片
					this.$Http({
						url: 'mergeCard',
						data: {
							activity_id: this.id
						},
						token: true
					}).then(res1 => {
						this.OnMyPlay()
						// this.OngetMessage()
						if (res1.code == 1) {
							//抽奖
							this.$Http({
								url: 'luckDrawPrize',
								data: {
									activity_id: this.id
								},
								token: true
							}).then(res2 => {
								//抽中奖品
								if (res2.code == 1) {
									res2.data.image = this.imgFullUrl + res2.data.image
									this.luckObj = res2.data
									this.$refs.popup7.open()
								} else if (res2.code == 0) {
									this.luckObj = {}
									//没抽中
									let info = ''
									if (res2.data == 1) {
										info = '抽奖未开始~请在规定时间内抽奖'
									} else if (res2.data == 2) {
										info = '非常抱歉,您的抽奖次已用完,您可以继续集卡后在来抽奖'
									} else if (res2.data == 3) {
										info = '抽奖已结束~'
									} else if (res2.data == 4) {
										info = '很遗憾,未中奖~'
									} else if (res2.data == 5) {
										info = '非常抱歉,库存不足请您稍后在试~'
									} else {
										info = res2.msg
									}
									this.popup5 = {
										title: '抽奖提示',
										info: info,
										button1: '我知道了',
										button1_is: 'close',
										button2: '',
										button2_is: ''
									}
									this.$refs.popup5.open()
								}
							});
						} else {
							this.popup5 = {
								title: '抽奖提示',
								info: res1.msg,
								button1: '我知道了',
								button1_is: 'close',
								button2: '',
								button2_is: ''
							}
							this.$refs.popup5.open()
						}
					});

				}
			},
			//打开弹窗
			Onopen(e, obj) {
				//转增弹窗
				if (e == 'popup1') {
					this.$refs.popup1.open()
					this.LoadIf1 = true
				}
				//活动规则
				if (e == 'popup2') {
					this.$refs.popup2.open()
				}
				//充值抽卡记录
				if (e == 'popup3') {
					this.$refs.popup3.open()
					this.LoadIf2 = true
				}
				//提示
				if (e == 'popup5') {
					if (obj.help||obj.give) {
						this.popup5 = {
							title: '求助提示',
							info: obj.help?'浏览器暂不支持求助好友,请切换到微信小程序':'浏览器暂不支持赠送纽卡,请切换到微信小程序',
							button1: '我知道了',
							button1_is: 'close',
							button2: '',
							button2_is: ''
						}
						this.$refs.popup5.open()
					}
				}
				//文字弹窗
				if (e == 'popup6') {
					if (obj.count > 0) {
						this.giveObj = obj
						this.popup6 = {
							title: '您确定要赠送纽卡出去吗?',
							info: '',
							type: 'give',
							button: '立即赠送',
						}
						this.$refs.popup6.open()
					}
				}
			},
			//关闭弹窗
			Onclose(e) {
				//转增弹窗
				if (e == 'popup1') {
					this.$refs.popup1.close()
					this.LoadIf1 = false
				}
				//活动规则
				if (e == 'popup2') {
					this.$refs.popup2.close()
				}
				//充值抽卡记录
				if (e == 'popup3') {
					this.$refs.popup3.close()
				}
				//抽卡
				if (e == 'popup4') {
					this.lucktext = ''
					this.flip = false
					this.$refs.popup4.close()
				}
				//错误弹窗提示5
				if (e == 'popup5') {
					this.$refs.popup5.close()
				}
				//错误弹窗提示6
				if (e == 'popup6') {
					this.$refs.popup6.close()
				}
				//中奖弹窗
				if (e == 'popup7') {
					this.$refs.popup7.close()
				}
			},
			//转增弹窗切换
			Onpop1head(e) {
				this.popup1index = e
				this.initData1.param.type = e
				this.$refs.LoadMore1.oncutRefresh(this.initData1)
			},
			//索回卡牌
			OngetBack(e) {
				let that = this
				uni.showModal({
					title: '收回提示',
					confirmText: '确认',
					confirmColor: that.color1,
					cancelText: '取消',
					content: '您确认要收回吗?',
					success: function(res) {
						if (res.confirm) {
							that.$Http({
								url: 'getBack',
								token: true,
								data: {
									activity_id: that.id,
									id: e.id
								},
								token: true
							}).then(res => {
								if (res.code == 1) {
									that.$refs.LoadMore1.oncutRefresh(that.initData1)
									that.OnMyPlay()
								} else {
									uni.showToast({
										icon: 'none',
										duration: 3000,
										title: res.msg
									});
								}
							})
						} else if (res.cancel) {

						}
						// uni.removeStorageSync('userInfo');
					}
				});
			},
			// LoadMore返回列表数据
			dataRefresh1(e) {
				this.GiveList = e
			},
			dataRefresh2(e) {
				this.BuyList = e
			},
			//跳转
			goNext(url, type) {
				if (type == 'popup3') {
					this.$refs.popup3.close()
				}
				if (type == 'popup7') {
					this.$refs.popup7.close()
				}
				this.$Router.push(url)
			},
		},
		//刷新
		onPullDownRefresh() {
			let that = this
			uni.showNavigationBarLoading()
			let OnMyPlay = new Promise((resolved, rejected) => {
				that.OnMyPlay(true, resolved)
			})
			let OngetMessage = new Promise((resolved, rejected) => {
				that.OngetMessage(true, resolved)
			})
			let Onhelp = new Promise((resolved, rejected) => {
				that.Onhelp(true, resolved)
				that.$forceUpdate()
			})
			Promise.all([OnMyPlay, OngetMessage]).then((result) => {
				uni.stopPullDownRefresh()
				uni.hideNavigationBarLoading()
			}).catch((error) => {})
		},
		//微信小程序分享
		onShareAppMessage(e) {
			let obj = e.target ? e.target.dataset : {}
			let that = this
			let shareObj = {}
			// 分享数据
			let paramStr = 'Pid.' + this.idInfo.Pid + ',Fid.' + this.idInfo.Fid;
			if (this.idInfo.Cid) {
				paramStr = paramStr + ',Cid.' + this.idInfo.Cid
			}
			let name = that.userInfo.user ? that.userInfo.user.name : '有人'
			return new Promise((resolve) => {
				//求助好友
				if (obj.button == 'help') {
					paramStr = paramStr + ',id.' + this.id + ',type.card'
					shareObj = {
						title: '[' + name + '@]你帮忙助力' + that.datainfo.name,
						path: '/pages/activity/common/help?scene=' + paramStr,
						imageUrl: that.imgFullUrl + that.datainfo.help.image,
					}
					that.$refs.popup5.close()
					console.log(shareObj)
					resolve(shareObj)
				} else if (obj.button == 'give') {
					//送卡片
					that.$Http({
						url: 'setGive',
						token: true,
						data: {
							activity_id: that.id,
							name: that.giveObj.name,
						},
					}).then(res1 => {
						if (res1.code == 1) {
							paramStr = paramStr + ',id.' + this.id + ',Gid.' + res1.data.id + ',type.give'
							shareObj = {
								title: name + '赠送您一张' + that.giveObj.name + '卡,快来领取~',
								path: '/pages/activity/card/index?scene=' + paramStr,
								imageUrl: that.imgFullUrl + that.datainfo.help.image,
							}
							that.OnMyPlay()
							that.$refs.popup6.close()
							resolve(shareObj)
						} else {
							that.$refs.popup6.close()
							that.popup5 = {
								title: '赠出卡牌提示',
								info: res1.msg,
								button1: '我知道了',
								button1_is: 'close',
								button2: '',
								button2_is: ''
							}
							that.$refs.popup5.open()
						}
					});
				} else {
					paramStr = paramStr + ',id.' + this.id + ',type.normal'
					shareObj = {
						title: that.datainfo.help.title,
						path: '/pages/activity/card/index?scene=' + paramStr,
						imageUrl: that.imgFullUrl + that.datainfo.help.image,
					}
					resolve(shareObj)
				}
			})

		}
	}
</script>

<style lang="less">
	@import url("style.less");
</style>
